package com.wechat.server.mp.controller;

import cn.hutool.json.JSONUtil;
import com.wechat.server.mp.common.dto.WxMenuKey;
import com.wechat.server.mp.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @description:
 * @author: stone
 * @date: Created by 2021/10/20 16:29
 * @version: 1.0.0
 * @pakeage: com.wechat.server.mp.controller
 */
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @PostMapping("/header")
    public R testHeader(@RequestBody WxMenuKey wxMenuKey, HttpServletRequest request) {
        log.info("请求的参数是 json ===> {}", JSONUtil.toJsonStr(wxMenuKey));

        String token = request.getHeader("token");
        String authorization = request.getHeader("authorization");
        log.info("获取请求头的参数是 token ===> {},authorization ===> {}", token, authorization);
        return R.ok().put("data", wxMenuKey);

    }
}
